<?php echo CHtml::scriptFile('assets/tiny_mce/tiny_mce.js'); ?>
<?php echo CHtml::scriptFile('assets/js/editor_tinymce.js'); ?>

<script type="text/javascript">
	//tinymce_image("image_map");
	tinymce_simple("content");
	//tinymce_advanced("content");
</script>

<div class="content">
	<div class="content_i">
    	
        <div class="list_button">
        	<?php $this->widget("application.modules.system.widgets.ConfigWidget"); ?>
        </div>

    <?php
		if (strlen($message))
		{
			echo "<div style='padding:5px; width:50%;  height:15px; background-color:#d8e9ff; 
				border-top: 1px solid #3474c2; border-bottom: 1px solid #3474c2;'>";
			echo $message ;
			echo "</div>";
		}
	?>
    <?php echo CHtml::beginForm(array($this->controller_id."/save_mail"),"post", array("id"=>"form_edit"));?>
    <table cellpadding="3" cellspacing="0" width="100%" border="0">
    	<tr>
        	<td width="50%" valign="top">
            	<?php
					echo "<h2>";
					echo CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-mail.png");
					echo " Cấu hình E-Mail";
					echo "</h2>";
					
					echo "<table cellpadding='3' cellspacing='0' border='0' width='100%'>";
					
						echo "<tr>";
							echo "<td class='label' width='120'>"."Mailer"."</td>";
							echo "<td>";
								$list_mailer = array();
								$list_mailer["mailer"] = "-- Mailer -- ";
								$list_mailer["phpfunction"] = " Php Function ";
								$list_mailer["smtp"] = " SMTP ";
								
								echo CHtml::dropDownList("mailer", $mailer["mailer"], $list_mailer);
							echo "</td>";
						echo "</tr>";
						
						echo "<tr>";
							echo "<td class='label' width='100'>"."Email From"."</td>";
							echo "<td>";
								echo CHtml::textField("email_from", $mailer["email_from"], 
								array('style'=>'width:99%'));
							echo "</td>";
						echo "</tr>";
						
						echo "<tr>";
							echo "<td class='label' width='100'>"."From Name"."</td>";
							echo "<td>";
								echo CHtml::textField("from_name", $mailer["from_name"], 
								array('style'=>'width:99%'));
							echo "</td>";
						echo "</tr>";
						
						echo "<tr>";
							echo "<td class='label' width='100'>"."SMTP Host"."</td>";
							echo "<td>";
								echo CHtml::textField("smtp_host", $mailer["smtp_host"], 
								array('style'=>'width:99%'));
							echo "</td>";
						echo "</tr>";
						
						echo "<tr>";
							echo "<td class='label' width='100'>"."SMTP Username"."</td>";
							echo "<td>";
								echo CHtml::textField("smtp_username", $mailer["smtp_username"], 
								array('style'=>'width:99%'));
							echo "</td>";
						echo "</tr>";
						
						
						echo "<tr>";
							echo "<td class='label' width='100'>"."SMTP Password"."</td>";
							echo "<td>";
								echo CHtml::textField("smtp_password", $mailer["smtp_password"], 
								array('style'=>'width:99%'));
							echo "</td>";
						echo "</tr>";
						
						echo "<tr>";
							echo "<td class='label' width='100'>"."SMTP Port"."</td>";
							echo "<td>";
								echo CHtml::textField("smtp_port", $mailer["smtp_port"], 
								array('style'=>'width:99%'));
							echo "</td>";
						echo "</tr>";
									
								
					echo "</table>";
					
				?>
            </td>
            
            <td valign="top">
            
            	<?php
					echo "<h2>";
					echo CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-copy.png");
					echo " Nội dung E-Mail";
					echo "</h2>";
					
					echo "<table cellpadding='3' cellspacing='0' border='0'>";
						echo "<tr>";
							echo "<td>";
								echo CHtml::textArea("content", $mailer["content"],
					 				array('style'=>'width:500px; height:200px;'));
							echo "</td>";
						echo "</tr>";
						
					echo "</table>";
				?>
            </td>
        </tr>
        
        
        <tr>
        	<td colspan="2">
            	<?php
					echo "<div class='space_5'></div>";
					echo "<div style='float:left; width:140px; height:20px;'></div>";
					echo 
						"<div class='button' id='button_submit'>" .
							"<div style='float:left; width:20px;'>" .
								CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-save.png") .
							"</div>" .
							"<div style='float:left; width:40px;font-weight:bold'>".
								"Save" .
							"</div>" .
						"</div>";
						
						
					echo " ";
					
					echo 
						"<div class='button' id='button_cancel'>" .
							"<div style='float:left; width:20px;'>" .
								CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-check.png") .
							"</div>" .
							"<div style='float:left; width:50px;font-weight:bold'>".
								"Reset" .
							"</div>" .
						"</div>";
						
				?>
            </td>
        </tr>
        
    </table>
    <?php echo CHtml::endForm(); ?>
    </div><!-- end div content_i -->
</div><!-- end div content -->

<script language="javascript">
$(document).ready(function(){
	$('#button_submit').click(function(){
		$('#form_edit').submit();
	});
	
	$('#button_cancel').click(function(){
		//alert("asdasD");
		$('#form_edit')[0].reset();
	});
});
</script>
